<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>全局、局部组件</title>
</head>

<body>
    <div id="app1">
        <my-head></my-head>
        <my-div></my-div>
        <my-p></my-p>
    </div>
    <div id="app2">
    </div>
    <script src="js/vue.js"></script>
    <script>
        //全局组件
        Vue.component("MyHead", {
            template: "<h1>这是头部</h1>"
        })
        // 创建Vue实例
        new Vue({
            el: '#app1',
            components: {
                "my-div": {
                    template: "<div>局部组件</div>"
                },
                "my-p": {
                    template: "<p> 局部组件2 </p>"
                }
            }
        });
        new Vue({
            el: '#app2'
        });
    </script>
</body>
</html>